﻿@{
    ViewData["Title"] = "添加位置管理";
    Layout = null;
    var resPosition = ViewBag.ResPosition as List<BuyWithoutLoseMoney.Core.Models.ResPosition>;
    var position = ViewBag.Position as List<BuyWithoutLoseMoney.Core.Models.Position>;
    var product = ViewBag.Product as BuyWithoutLoseMoney.Core.Models.Product;
}

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Edit</title>
    <link href="/layui/css/layui.mobile.css" rel="stylesheet" />
    <link href="/layui/css/layui.css" rel="stylesheet" />
</head>
<body>

    <div>
        <div class="layui-card">
            <div class="layui-card-header">添加位置管理</div>
            <div class="layui-card-body">
                <form class="layui-form">
                    <div class="layui-form-item">
                        <label class="layui-form-label">位置类型</label>
                        <div class="layui-input-block">
                            <select name="PositionId" lay-verify="required">
                                @foreach (var item in position)
                                {
                                    <option value="@item.Id">@item.Name</option>
                                }
                            </select>
                        </div>
                    </div>
                        @*<select name="ResId" lay-verify="required">
                        <option value="@product.Id">@item.Title</option>
                        </select>*@
                        <input type="hidden" name="ResId" value="@product.Id" required lay-verify="required" placeholder="请输入产品标题" autocomplete="off" class="layui-input">
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="addForm">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script src="/js/vue.js"></script>
    <script src="/layui/layui.js"></script>
    <script>
        layui.use(["form", 'layer'], function() {
            var form = layui.form;
            var $ = layui.$;
            var layer = layui.layer;
            //提交
            form.on('submit(addForm)', function(data) {
                $.post("/admin/position/Create", data.field, function(res) {
                    if (res.isSuccess) {
                        layer.msg(res.msg, function() {
                            parent.window.location.href = "/admin/product/index";
                        });
                    } else {
                        layer.msg(res.msg);
                    }
                });
                return false;
            });
        })
    </script>
</body>
</html>